#include <iostream>
#include <pthread.h>
#include <unistd.h>
#include <sys/types.h>

using namespace std;

//创建新的线程
void *newthreadrun(void *args)
{
    while(true)
    {
        cout<<"I am a new thread,pid:"<<getpid()<<endl;
        sleep(1);
    }
}

int main()
{
    pthread_t tid;
    pthread_create(&tid,nullptr,newthreadrun,nullptr);

    while(true)
    {
        cout<<"I am a old thread,pid:"<<getpid()<<endl;
        sleep(1);
    }

    return 0;
}